// 百度地图ak注册脚本
export const loadBMap = (ak) => {
  return new Promise(function(resolve, reject) {
    if (typeof BMap !== 'undefined') {
      resolve(BMap)
      return true
    }
    window.onBMapCallback = function() {
      resolve(BMap)
    }
    const script = document.createElement('script')
    script.type = 'text/javascript'
    script.src =
          'http://api.map.baidu.com/api?v=2.0&ak=' + 'SHTgRvmsmMditkvnt9V4H7oGtz6GXpDc' + '&callback=onBMapCallback'
    script.onerror = reject
    document.head.appendChild(script)
  })
}
